//
//  QuickLoanSearchView.swift
//  KaMengApplication
//
//  Created by DUONIU_MAC on 2018/12/14.
//  Copyright © 2018年 DUONIU_MAC. All rights reserved.
//

import UIKit

class QuickLoanSearchView: UIView {
    
    let searchView = UITextField.init(Width: RATIO(maxNum: 5))
    let searchButton = UIButton()

    init() {
        super.init(frame: .zero)
        
        self.backgroundColor = UIColor.white
    
        searchButton.backgroundColor = UIColor.red
        searchButton.setTitle(search_title, for: .normal)
        searchButton.titleLabel?.font = UIFont.systemFont(ofSize: RATIO(maxNum: 16))
        searchButton.layer.cornerRadius = 5
        searchButton.layer.masksToBounds = true
        self.addSubview(searchButton)
        
        let borderView = UIView()
        borderView.layer.borderColor = UIColor.lineColor().cgColor
        borderView.layer.borderWidth = 1
        borderView.layer.cornerRadius = 5
        borderView.layer.masksToBounds = true
        self.addSubview(borderView)
        
        let searchImage = UIImageView()
        searchImage.image = UIImage.init(named: "ksdk_search")
        borderView.addSubview(searchImage)
        
        let millionLabel = UILabel()
        millionLabel.text = millionYuan
        millionLabel.textColor = UIColor.gray
        millionLabel.font = UIFont.systemFont(ofSize: RATIO(maxNum: 16))
        millionLabel.textAlignment = .right
        borderView.addSubview(millionLabel)
        
        searchView.placeholder = inputLoanAmount
        searchView.font = UIFont.systemFont(ofSize: RATIO(maxNum: 16))
        searchView.keyboardType = .decimalPad
        borderView.addSubview(searchView)
        
        searchButton.snp.makeConstraints { (make) in
            make.right.equalToSuperview().offset(RATIO(maxNum: -10))
            make.top.equalToSuperview().offset(RATIO_H(maxNum: 10))
            make.bottom.equalToSuperview().offset(RATIO_H(maxNum: -10))
            make.width.equalTo(RATIO(maxNum: 80))
        }
        
        borderView.snp.makeConstraints { (make) in
            make.right.equalTo(searchButton.snp.left).offset(RATIO(maxNum: -10))
            make.left.equalToSuperview().offset(RATIO(maxNum: 10))
            make.top.bottom.equalTo(searchButton)
        }
        
        searchImage.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(RATIO(maxNum: 5))
            make.centerY.equalToSuperview()
            make.width.height.equalTo(RATIO_H(maxNum: 20))
        }
        
        millionLabel.snp.makeConstraints { (make) in
            make.right.equalToSuperview().offset(RATIO(maxNum: -5))
            make.centerY.height.equalToSuperview()
            make.width.equalTo(RATIO_H(maxNum: 40))
            
        }
        
        searchView.snp.makeConstraints { (make) in
            make.centerY.height.equalToSuperview()
            make.left.equalTo(searchImage.snp.right)
            make.right.equalTo(millionLabel.snp.left)
        }
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}
